 (function(){
 	/*
	 * @copyright
	 * GCS video conference for Google+ Hangouts
	 * Copyright (c) 2013 Moritz Tolxdorff & Martin Thielecke
	 * 
 	 * You should have received a copy of the GNU General Public License
 	 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
	 *
	*/	
	/**
	 * @GCS video conference for Google+ Hangouts
	 * @constructor
	*/
	function GTKHangoutApps(){
		if(!gapi){
			throw "gapi not loaded!";
		}

		/**
		 * @MemeFace.maxHeight - defines the maximum window height
		 * @public
		 * @const 
		 * @type {Number}
		*/
        if(window.innerHeight > 0) {
		  this.maxHeight = window.innerHeight;
        } else {
		  this.maxHeight = $(window).height();
        }
		/*
		 * Bind gapi events when API is ready
		*/
		gapi.hangout.onApiReady.add(this.onApiReady.bind(this));
	}

	/**
	 * @scale - Scales the mainbody for different resolutions
	 * @public
	*/
	GTKHangoutApps.prototype.scale = function(){
		/*
		 * Set the maximum height of the mainbody minus header, input div and footer
		*/
		jQuery("#mainframe").height(this.maxHeight-57);
	}
	
	/**
	 * @onApiReady - Fired by gapi when it's ready
	 * @private
	 * @param event {gapi.hangout.apiReadyEvent}
	*/
	GTKHangoutApps.prototype.onApiReady = function(event){
		if(event.isApiReady){
			try {
				console.log("Gemtek Hangout conference loaded!");

				//Construct main framework GUI
				$("#mainframe").tabs();
				
				//Prepare global variable
				window.arrMessages = new Array(); //Chat room log in client
				window.topic = null;
				window.participantNum = 1;

//Get person information from hangout
				var me = gapi.hangout.getLocalParticipant();
				window.displayIndex = me.displayIndex;
				window.myDisplayName = me.person.displayName;
				window.myParticipantID = me.id;
				window.myPersonID = me.person.id.toString();
				
				//Init all function
				var participantslist = new participantsList();
				participantslist.init();

				var sessioninfo = new sessionInfo();
				sessioninfo.init();
				
				var intrduction = new Intrduction();
				intrduction.init();
			}	
			catch(err) {
				console.log(err);
			}
		}
	}

	// Export instantiated HangoutToolBox to main window
	window["appController"] = new GTKHangoutApps();
})()
